package com.carefree.system.modules.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.carefree.common.core.PageUtils;
import com.carefree.common.core.QueryParam;
import com.carefree.system.modules.admin.dao.OperLogDao;
import com.carefree.system.modules.admin.entity.OperLogEntity;
import com.carefree.system.modules.admin.service.OperLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


/**
 * 操作日志
 *
 * @author tengbin
 */
@Service("operLogService")
public class OperLogServiceImpl extends ServiceImpl<OperLogDao, OperLogEntity> implements OperLogService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<OperLogEntity> queryWrapper = new QueryWrapper<>();
        String keyword = (String) params.get("keyword");
        if (StringUtils.isNoneBlank(keyword)) {
            queryWrapper.like("title", keyword)
                    .or()
                    .like("method", keyword)
                    .or()
                    .eq("request_method", keyword);
        }
        IPage<OperLogEntity> page = page(new QueryParam<OperLogEntity>().getPage(params), queryWrapper);
        return new PageUtils(page);
    }

}
